﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace System.Windows
{
    /// <summary>
    /// A value class which expresses a range of two <see cref="System.Double"/> values.
    /// </summary>
    public class DoubleRange
    {
        /// <summary>
        /// Initalizes a <see cref="DoubleRange"/> object.
        /// </summary>
        public DoubleRange()
        {
            this.Minimum = this.Maximum = 0;
        }

        /// <summary>
        /// Initalizes a <see cref="DoubleRange"/> object.
        /// </summary>
        /// <remarks>
        /// The range is normalized by this contructor.
        /// </remarks>
        /// <param name="min">The minimum of the range</param>
        /// <param name="max">The maximum of the range</param>
        public DoubleRange(double min, double max)
        {
            this.Minimum = Math.Min(min, max);
            this.Maximum = Math.Max(max, min);
        }

        /// <summary>
        /// Returns a <see cref="DoubleRange"/> object which is considered to be an empty value.
        /// </summary>
        public static DoubleRange Empty
        {
            get { return new DoubleRange(); }
        }

        private double  _Min;
        private double  _Max;

        /// <summary>
        /// Gets/Sets the Minimum value for the range.
        /// </summary>
        public double Minimum
        {
            get { return _Min; }
            set { _Min = value; }
        }

        /// <summary>
        /// Gets/Sets the Maximum value for the range.
        /// </summary>
        public double Maximum
        {
            get { return _Max; }
            set { _Max = value; }
        }

        /// <summary>
        /// Gets total range as a <see cref="System.Double"/> value.
        /// </summary>
        public double Range
        {
            get { return this.Maximum - this.Minimum; }
        }

        /// <summary>
        /// Gets absolute range as a <see cref="System.Double"/> value.
        /// </summary>
        public double AbsoluteRange
        {
            get { return Math.Abs(this.Range); }
        }
    }
}
